<template>
  <div class="loginpublicWarp">
    <!-- logo -->
    <div class="logo">
      <img src="../../../static/images/login/logo@2x.png" alt="" />
    </div>

    <!-- 手机号 -->
    <!-- onSubmit仅在提交表单时触发校验 -->
    <div class="formlist">
      <van-form @submit="onSubmit">
        <slot name="inputslot"> </slot>
        <div style="margin: 12px">
          <van-button square type="primary" size="large">
            <!-- 底部组件 -->
            <slot name="btn"></slot>
          </van-button>
        </div>
      </van-form>
    </div>
  </div>
</template>

<script>
export default {
  props: ["phone", "password",'user'],
  data() {
    return {
 
      };
  },
  methods: {
    onSubmit(values) {
      // console.log(this.$emit("sendcode")==true);
      // console.log(this.$parent.sendcode.return);
      // alert(this.$parent.sendcode+"____"+this.$parent.passwordf)
      // if(this.$emit("sendcode")==true&&this.$emit("passwordf")==true){
      // console.log(this.phone);
      // console.log(this.password);
      // console.log(this.user)
      // console.log(localStorage.getItem("telPhone"));
    if(this.user=='2'){
      // 本地存值
      localStorage.setItem("telPhone", this.phone);
      localStorage.setItem("password", this.password);
      this.$router.push({ path: "/login" });
    }else if(this.user=='1'){
        if(this.phone==localStorage.getItem("telPhone")&&this.password==localStorage.getItem("password")){
          this.$router.push({ path: "/home" });
        }else{
          // this.$router.push({ path: "/register" });
           this.$toast('用户不存在，请前往注册');
        }
    }else{
      if(this.phone==localStorage.getItem("telPhone")){
          localStorage.setItem("telPhone", this.phone);
          localStorage.setItem("password", this.password);
           this.$router.push({ path: "/login" });
      }else{
         this.$toast('用户不存在');
      }
    }
    // }
    },
  },
};
</script>

<style lang="less" scoped>
.loginpublicWarp {
  /deep/.van-field__control{
    width: 240px;
  }
  padding-top: 20px;
  .van-button--primary {
    color: #fff;
    background-color: red;
    border: 1px solid red;
  }
  .logo {
    margin-top: 60px;
    margin-left: 304px;
    margin-right: 290px;

    img {
      width: 142px;
      height: 142px;
    }
  }
  .formlist {
    margin: 14px;
    button {
      width: 670px;
      height: 103px;
    }
    .van-cell {
      line-height: 70px;
    }
  }
}
</style>